﻿@model NUS.ISS.SRKBS.UI.Models.Regulatory

@{
    if (ViewBag.DisplayForm != null)
    {    
    using (Ajax.BeginForm("RegulatoryRuleTriggerAuto", "Regulatory", new AjaxOptions
    {
        UpdateTargetId = "divBatteryType",
        InsertionMode = InsertionMode.Replace,
        HttpMethod = "POST"
    }))
    {
    <fieldset>        
        <table>            
            <tr>
                <td>@Html.LabelFor(m => m.BatteryType)</td>
                <td>
                    @Html.RadioButtonFor(m => m.BatteryType, "PRIMARY", new { id = "Battery_Primary" }) @Html.Label("Primary", new { @class = "radio" })
                    @Html.RadioButtonFor(m => m.BatteryType, "SECONDARY", new { id = "Battery_Secondary" }) @Html.Label("Secondary", new { @class = "radio" })                    
                </td>
            </tr>
        </table>        
    </fieldset>
    }
    }
}

<script language="javascript" type="text/javascript">
    $(document).ready(function () {
        $("#Battery_Primary").change(function () {
            var selected_type = $(this).val();
            var url = '@Url.Action("RegulatoryRuleTriggerAuto", "Regulatory")';
            $.post(url, { AttrName: "battery_type", AttrValue: selected_type },
            function (data) {
                $('#divBatteryType').empty().html(data);
            });

        });

        $("#Battery_Secondary").change(function () {
            var selected_type = $(this).val();
            var url = '@Url.Action("RegulatoryRuleTriggerAuto", "Regulatory")';
            $.post(url, { AttrName: "battery_type", AttrValue: selected_type },
                function (data) {
                    $('#divBatteryType').empty().html(data);
                });
        });
    });

   
</script>

<div id="divBatteryType">
    @{Html.RenderPartial("_RegulatoryRuleAuto", Model);}       
</div>